<script setup>

import { defineProps, defineEmits } from 'vue'
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false
  }
})
const emit = defineEmits(['update:modelValue'])
const toggleFn = () => {
  emit('update:modelValue', !props.modelValue)
  // emit('toggleFn', !props.modelValue)
}

</script>
<template>
    <div class="xtx-checkbox" @click="toggleFn">
        <i v-if="modelValue" class="iconfont icon-checked"></i>
        <i  v-else class="iconfont icon-unchecked"></i>
        <span><slot></slot></span>
    </div>
</template>
<style scoped lang="less">
.xtx-checkbox{
    display: inline-block;
    margin-right: 2px;
    .icon-checked{
        color: @xtxColor;
        ~ span{
        color: @xtxColor;
       }
    }
    i{
        position: relative;
        top: 1px;
    }
    span{
        margin-left: 2px;
    }
}
</style>
